//
//  ScrollPartView.m
//  ZiJinLian
//
//  Created by 震霄 张 on 2018/3/10.
//  Copyright © 2018年 lzy. All rights reserved.
//

#import "ScrollPartView.h"

@interface ScrollPartView()
@property (weak, nonatomic) IBOutlet UIButton *bgBtn;
@property (weak, nonatomic) IBOutlet UIView *numBgView;
@property (weak, nonatomic) IBOutlet UILabel *numLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *detialLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleRightDistance;

@end
@implementation ScrollPartView

+(instancetype)scrollPartView
{
	return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;

}
-(void)awakeFromNib
{
	[super awakeFromNib];
	self.autoresizingMask = UIViewAutoresizingNone;
	self.bgBtn.layer.cornerRadius = 3;
	self.bgBtn.clipsToBounds = YES;
	self.numBgView.layer.cornerRadius = 3;
	self.numBgView.clipsToBounds = YES;
	
//	[self.iconView setContentScaleFactor:[[UIScreen mainScreen] scale]];
	self.iconView.contentMode = UIViewContentModeScaleAspectFill;
	self.iconView.clipsToBounds = YES;
	self.priceLabel.hidden = YES;
	self.titleRightDistance.constant = 10;
}
- (IBAction)bgBtnClick:(id)sender {
	NSLog(@"click");
	
	if (self.isNEW == NO) {
		NSMutableDictionary *dic = [NSMutableDictionary dictionary];
		[dic setValue:@"1" forKey:@"type"];
		[dic setValue:self.model.imageLink forKey:@"value"];
		[[NSNotificationCenter defaultCenter]postNotificationName:@"jumpOther" object:nil userInfo:dic];
	}else{
		NSMutableDictionary *dic = [NSMutableDictionary dictionary];
		[dic setValue:@"2" forKey:@"type"];
		[dic setValue:[NSString stringWithFormat:@"%ld",self.NEWModel.spuId] forKey:@"value"];
		[[NSNotificationCenter defaultCenter]postNotificationName:@"jumpOther" object:nil userInfo:dic];
	}

	
}
-(void)setModel:(HomeEventModel *)model
{
	_model = model;
	[self.iconView sd_setImageWithURL:[NSURL URLWithString:model.imageUrl] placeholderImage:[UIImage imageNamed:@""]];
	self.titleLabel.text = model.title;
	self.detialLabel.text = model.content;
	self.numLabel.text = [NSString stringWithFormat:@"%ld",model.count];
}

-(void)setNEWModel:(HomeNewModel *)NEWModel
{
	_NEWModel = NEWModel;
	[self.iconView sd_setImageWithURL:[NSURL URLWithString:NEWModel.imgUrl] placeholderImage:[UIImage imageNamed:@""]];
	self.titleLabel.text = NEWModel.spuName;
	self.detialLabel.text = NEWModel.describe;
	self.priceLabel.text = [NSString stringWithFormat:@"¥%@起",NEWModel.bottomPrice];

}
-(void)setIsNEW:(BOOL)isNEW
{
	_isNEW = isNEW;
	self.numBgView.hidden = isNEW;
	self.priceLabel.hidden = NO;
	self.titleRightDistance.constant = 100;

}
@end
